package com.qqls.youxiangousys.pj.sys.controller;

import com.qqls.youxiangousys.pj.common.entity.JsonResult;
import com.qqls.youxiangousys.pj.common.entity.Pagination;
import com.qqls.youxiangousys.pj.sys.entity.SysCarousel;
import com.qqls.youxiangousys.pj.sys.service.realm.SysCarouselService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("carousel")
public class SysCarouselController {
    @Autowired
    private SysCarouselService carService;

    //查所有
    @RequestMapping("findAll")
    public JsonResult findAll(String carouselTitle, Integer curPage, Integer pageSize){
        Pagination pageObj = carService.findAll(carouselTitle,curPage,pageSize);
        return new JsonResult(pageObj);
    }
    //状态
    @RequestMapping("updateValId")
    public JsonResult updateValId(Integer id,Integer carState){
            JsonResult jr =new JsonResult(carService.updateValId(id,carState));
            jr.setMessage("修改成功");
        return jr;
    }
    //添加
    @RequestMapping("addCar")
    public JsonResult addCar(SysCarousel car){
        JsonResult jr=new JsonResult(carService.addCar(car));
        jr.setMessage("添加成功!");
        return jr;
    }

    //删除
    @RequestMapping("delete")
    public JsonResult delete(@RequestParam(required = false,value = "ids[]")Integer[] ids){
        return new JsonResult(carService.delete(ids));
    }
    //修改
    @RequestMapping("updateCar")
    public JsonResult findCarById(SysCarousel carousel){
        JsonResult jr=new JsonResult(carService.updateCar(carousel));
        jr.setMessage("修改成功");
        return jr;
    }
}
